package com.yesallchina.wxapp.officialaccount.api.beans.param;

import com.yesallchina.wxapp.officialaccount.utils.XmlUtils;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

/**
 * 统一下单参数信息
 */
@XmlRootElement(name = "xml")
public class PayParam implements Serializable {
    private String appId;
    private String mchId;
    private String nonceStr;
    private String sign;
    private String signType;
    private String feeType;
    private String notifyUrl;
    /**
     * 交易号
     */
    @NotBlank(message = "唯一交易号错误")
    @Length(max = 32, message = "交易号长度最大32位")
    private String tradeId;

    /**
     * 本次交易描述
     */
    @NotBlank(message = "交易描述错误，一般为商品名称")
    @Length(max = 128, message = "交易描述长度最大128位")
    private String body;

    /**
     * 商品ID,当tradeType=Native时不可为空
     */
    private String productId;

    /**
     * 附加扩展内容，会在响应结果中原样返回，最大长度127
     */
    private String attach;

    /**
     * 标价，单位分
     */
    @NotNull(message = "商品总价错误，单位：分")
    private Integer totalFee;

    /**
     * 终端IP，网页调用是网页终端IP
     * APP调用，是服务端IP
     */
    @NotBlank(message = "终端IP错误")
    private String spbillCreateIp = "127.0.0.1";

    /**
     * 交易开始时间，格式yyyyMMddHHmmss
     */
    private String timeStart;

    /**
     * 交易结束时间，与开始时间最低相隔5分钟，格式yyyyMMddHHmmss
     */
    private String timeExpire;

    /**
     * 交易类型，取值如下：JSAPI，NATIVE，APP
     */
    private String tradeType;

    /**
     * tradeType=JSAPI的时，必须
     */
    private String openid;


    @XmlElement(name = "out_trade_no")
    public String getTradeId() {
        return tradeId;
    }

    public void setTradeId(String tradeId) {
        this.tradeId = tradeId;
    }

    @XmlElement(name = "body")
    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    @XmlElement(name = "product_id")
    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    @XmlElement(name = "attach")
    public String getAttach() {
        return attach;
    }

    public void setAttach(String attach) {
        this.attach = attach;
    }

    @XmlElement(name = "total_fee")
    public Integer getTotalFee() {
        return totalFee;
    }

    public void setTotalFee(Integer totalFee) {
        this.totalFee = totalFee;
    }

    @XmlElement(name = "spbill_create_ip")
    public String getSpbillCreateIp() {
        return spbillCreateIp;
    }

    public void setSpbillCreateIp(String spbillCreateIp) {
        this.spbillCreateIp = spbillCreateIp;
    }

    @XmlElement(name = "time_start")
    public String getTimeStart() {
        return timeStart;
    }

    public void setTimeStart(String timeStart) {
        this.timeStart = timeStart;
    }

    @XmlElement(name="time_expire")
    public String getTimeExpire() {
        return timeExpire;
    }

    public void setTimeExpire(String timeExpire) {
        this.timeExpire = timeExpire;
    }

    @XmlElement(name = "trade_type")
    public String getTradeType() {
        return tradeType;
    }

    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }

    @XmlElement(name = "openid")
    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    @XmlElement(name = "appid")
    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    @XmlElement(name="mch_id")
    public String getMchId() {
        return mchId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    @XmlElement(name="nonce_str")
    public String getNonceStr() {
        return nonceStr;
    }

    public void setNonceStr(String nonceStr) {
        this.nonceStr = nonceStr;
    }

    @XmlElement(name="sign")
    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    @XmlElement(name = "sign_type")
    public String getSignType() {
        return signType;
    }

    public void setSignType(String signType) {
        this.signType = signType;
    }

    @XmlElement(name = "fee_type")
    public String getFeeType() {
        return feeType;
    }

    public void setFeeType(String feeType) {
        this.feeType = feeType;
    }

    @XmlElement(name="notify_url")
    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    @Override
    public String toString() {
        return XmlUtils.beanToXml(this);
    }

}
